package com.google.code.fulltank.price;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.Map;
import org.joda.time.LocalDate;

/**
 * Israeli fuel prices (2005-01-02 to 2009-05-01).
 * @see http://www.mni.gov.il/mni/he-il/Energy/Fuel/FuelData/PricesatStation.htm
 * 
 * @author DL
 */
public class IsraeliFuelPriceHistory implements FuelPriceHistory {
    public IsraeliFuelPriceHistory() throws Exception {
        DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");

        firstDate = LocalDate.fromDateFields(dateFormat.parse("2/1/2005"));
        lastDate = LocalDate.fromDateFields(dateFormat.parse("1/5/2009"));

        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("2/1/2005")), 4.67);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("1/2/2005")), 4.98);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("1/3/2005")), 4.96);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("1/4/2005")), 5.24);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("1/5/2005")), 5.37);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("1/6/2005")), 5.11);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("1/7/2005")), 5.52);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("1/8/2005")), 5.55);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("1/9/2005")), 5.79);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("1/10/2005")), 5.83);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("2/10/2005")), 6.12);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("1/11/2005")), 5.52);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("1/12/2005")), 5.35);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("1/1/2006")), 5.42);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("1/2/2006")), 5.74);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("1/3/2006")), 5.61);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("2/4/2006")), 5.90);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("1/5/2006")), 6.21);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("1/6/2006")), 6.19);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("1/7/2006")), 6.17);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("2/7/2006")), 6.23);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("1/8/2006")), 6.40);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("1/9/2006")), 5.86);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("1/10/2006")), 5.37);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("1/11/2006")), 5.39);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("1/12/2006")), 5.43);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("1/1/2007")), 5.40);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("1/2/2007")), 5.20);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("1/3/2007")), 5.47);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("1/4/2007")), 5.73);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("1/5/2007")), 5.99);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("1/6/2007")), 6.07);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("1/7/2007")), 6.17);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("1/8/2007")), 6.04);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("2/9/2007")), 5.80);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("1/10/2007")), 5.97);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("1/11/2007")), 6.13);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("2/12/2007")), 6.30);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("1/1/2008")), 6.23);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("1/2/2008")), 5.98);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("2/3/2008")), 6.20);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("1/4/2008")), 6.29);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("1/5/2008")), 6.58);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("1/6/2008")), 6.73);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("1/7/2008")), 7.00);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("1/8/2008")), 6.67);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("1/9/2008")), 6.69);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("2/10/2008")), 6.35);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("2/11/2008")), 5.49);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("1/12/2008")), 5.00);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("1/1/2009")), 4.75);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("1/2/2009")), 5.08);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("1/3/2009")), 5.04);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("1/4/2009")), 5.46);
        fuelPrices.put(LocalDate.fromDateFields(dateFormat.parse("1/5/2009")), 5.44);
    }

    /** @see FuelPriceHistory#getUpdatedFuelPrice */
    public Double getUpdatedFuelPrice(LocalDate date) {
        return fuelPrices.get(date);
    }

    /** @see FuelPriceHistory#getFirstDate */
    public LocalDate getFirstDate() {
        return firstDate;
    }

    /** @see FuelPriceHistory#getLastDate */
    public LocalDate getLastDate() {
        return lastDate;
    }

    private final Map<LocalDate, Double> fuelPrices =
        new HashMap<LocalDate, Double>();
    
    private final LocalDate firstDate;
    private final LocalDate lastDate;
}
